package hot100;

public class Solution300 {

    public int lengthOfLIS(int[] nums) {
        if (nums == null || nums.length == 0) {
            return 0;
        }
        int[] dp = new int[nums.length];
        dp[0] = 1;
        int max = 1;
        for (int i = 0; i < nums.length; i++) {
            // 只包括当前数本身，即前面都是递减数列时
            dp[i] = 1;
            for (int j = 0; j < i; j++) {
                if (nums[i] > nums[j]) {
                    dp[i] = Math.max(dp[i], dp[j] + 1);
                }
            }
            max = Math.max(max, dp[i]);
        }
        return max;
    }

    public static void main(String[] args) {
        Solution300 solution300 = new Solution300();
        int[] input = new int[]{4,10,4,3,8,9};
        System.out.println(solution300.lengthOfLIS(input));
        input = new int[]{0, 1, 0, 3, 2, 3};
        System.out.println(solution300.lengthOfLIS(input));
    }
}
